﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="UpdateServices"
    targetNamespace="Sherwood.Content.Contracts"
    elementFormDefault="qualified"
    xmlns="Sherwood.Content.Contracts"
    xmlns:mstns="Sherwood.Content.Contracts"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:element name="updateRecordsRequest" type="updateRecordsRequest" />

  <xs:complexType name="updateRecordsRequest">
    <xs:sequence>
      <xs:element name="content">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="record" type="record" minOccurs="0" maxOccurs="unbounded" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="client" type="client" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="record">
    <xs:sequence>
      <xs:element name="title" minOccurs="0">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="512" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="description" minOccurs="0">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="4096" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="meta" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType mixed="true">
          <xs:sequence>
            <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
          </xs:sequence>
          <xs:attribute name="handler" use="required" type="xs:string"/>
          <xs:attribute name="usageKey"  type="xs:string" />
          <xs:attribute name="updateMode" type="updateMode" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="cultureInvariantReferenceId">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:maxLength value="512" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="referenceId">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:maxLength value="512" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="clientId">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:maxLength value="32" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="culture">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:pattern value="\w{1,3}\-\w{1,3}" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="language">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:pattern value="\w{2,3}" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="id" type="guid" />
    <xs:attribute name="updateMode" type="updateMode" use="required" />
  </xs:complexType>

  <xs:simpleType name="updateMode">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Create" />
      <xs:enumeration value="Update" />
      <xs:enumeration value="CreateOrUpdate" />
      <xs:enumeration value="Remove" />
    </xs:restriction>
  </xs:simpleType>
  
  <xs:complexType name="client">
    <xs:sequence>
      <xs:element name="signature" minOccurs="0" maxOccurs="1"  type="xs:string" />
    </xs:sequence>
    <xs:attribute name="id" use="required"  type="xs:string" />
  </xs:complexType>

  <xs:simpleType name="guid">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        The representation of a GUID, generally the id of an element.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"/>
    </xs:restriction>
  </xs:simpleType>


</xs:schema>